﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace NETXPF.Library
{
    /// <summary>
    /// This class is now obsolete (8/22/2011). Use 'Encryption' class instead, with the 'AES' methods.
    /// </summary>
    public static class AESEncryption
    {
        public const string DEFAULT_HASH_METHOD = Encryption.AES_DEFAULT_HASH_METHOD;
        public const string DEFAULT_IV = Encryption.AES_DEFAULT_IV;

        #region Static Functions

        /// <summary>
        /// Encrypts a string
        /// </summary>
        /// <param name="PlainText">Text to be encrypted</param>
        /// <param name="Password">Password to encrypt with</param>
        /// <param name="Salt">Salt to encrypt with</param>
        /// <param name="HashAlgorithm">Can be either SHA1 or MD5</param>
        /// <param name="PasswordIterations">Number of iterations to do</param>
        /// <param name="InitialVector">Needs to be 16 ASCII characters long</param>
        /// <param name="KeySize">Can be 128, 192, or 256</param>
        /// <returns>An encrypted string</returns>
        public static string Encrypt(string PlainText, string Password,
            string Salt, string HashAlgorithm,
            int PasswordIterations, string InitialVector,
            int KeySize)
        {
            return Encryption.EncryptAES(PlainText, Password, Salt, HashAlgorithm, PasswordIterations, InitialVector, KeySize); //retained for backwards compatibility
        }

        /// <summary>
        /// Decrypts a string
        /// </summary>
        /// <param name="CipherText">Text to be decrypted</param>
        /// <param name="Password">Password to decrypt with</param>
        /// <param name="Salt">Salt to decrypt with</param>
        /// <param name="HashAlgorithm">Can be either SHA1 or MD5</param>
        /// <param name="PasswordIterations">Number of iterations to do</param>
        /// <param name="InitialVector">Needs to be 16 ASCII characters long</param>
        /// <param name="KeySize">Can be 128, 192, or 256</param>
        /// <returns>A decrypted string</returns>
        public static string Decrypt(string CipherText, string Password,
            string Salt, string HashAlgorithm,
            int PasswordIterations, string InitialVector,
            int KeySize)
        {
            return Encryption.DecryptAES(CipherText, Password, Salt, HashAlgorithm, PasswordIterations, InitialVector, KeySize);
        }

        #endregion
    }
}